package com.itheima.health.controller.admin;

import com.itheima.health.common.MessageConst;
import com.itheima.health.result.Result;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 会员数量折线图统计
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        return new Result(true, MessageConst.GET_MEMBER_NUMBER_REPORT_SUCCESS,reportService.getMemberReport());
    }
    /**
     * 展示套餐分布情况
     * @return
     */
    @RequestMapping("/getSetmealReport")
    public Result getSetmealReport(){

        return new Result(true,MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS, reportService.getSetmealReport());
    }

    /**
     * 运营数据统计
     * @return
     */
    @RequestMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
        return new Result(true,MessageConst.GET_BUSINESS_REPORT_SUCCESS,reportService.getBusinessReportData());
    }

    /**
     * 导出Excel报表
     * @return
     */
    @RequestMapping("/exportBusinessReport")
    public Result exportBusinessReport(HttpServletResponse response){
        reportService.exportBusinessReport(response);
        return new Result(true,MessageConst.UPLOAD_SUCCESS);
    }
}
